/**
 * <p>Copyright (c) 2017 深圳市鹏途交通科技有限公司 </p>
 * <p>				   All right reserved. 		     </p>
 * 
 * <p>项目名称 ： 	深圳市国省检日常化监管系统         </p>
 * <p>创建者   :	win7 
 * 
 * <p>描   述  :   FundGuaranteeServiceImpl.java for com.pengtu.gsj.service.impl.zhgl    </p>
 * 
 * <p>最后修改 : $: 2017年8月16日-上午10:28:49 v 1.0.0	 win7   $ </p>
 * 
*/

package com.pengtu.gsj.service.impl.zhgl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.pengtu.gsj.dao.base.Page;
import com.pengtu.gsj.dao.base.QueryFilter;
import com.pengtu.gsj.dao.zhgl.FundGuaranteeDao;
import com.pengtu.gsj.entity.app.Attachment;
import com.pengtu.gsj.entity.zhgl.FundGuarantee;
import com.pengtu.gsj.service.system.SystemManageService;
import com.pengtu.gsj.service.zhgl.FundGuaranteeService;

/**
 * 
 * FundGuaranteeServiceImpl
 * 
 * 2017年8月16日 上午10:28:49
 * 
 * @version 1.0.0
 * 
 */
@Service
@Transactional
public class FundGuaranteeServiceImpl implements FundGuaranteeService {
	
	@Autowired
	private FundGuaranteeDao fundGuaranteeDao;
	
	@Autowired
	private SystemManageService systemManageService;
	
	
	
	@Override
	public void saveFundGuarantee(FundGuarantee fundGuarantee){
		fundGuaranteeDao.save(fundGuarantee);
	}
	
	@Override
	public Page<FundGuarantee> findFundGuarantee(Page<FundGuarantee> page, final QueryFilter queryFilter){
		return fundGuaranteeDao.findPage(page, queryFilter);
	}
	
	@Override
	public FundGuarantee getFundGuaranteeById(String id){
		return fundGuaranteeDao.get(id);
	}
	
	@Override
	public void  delateFundGuarantee(FundGuarantee fundGuarantee){
		if(fundGuarantee.getAttachments() != null){
			for(Attachment attachment : fundGuarantee.getAttachments()){
				systemManageService.deleteAttachment(attachment);
			}
		}
		fundGuaranteeDao.delete(fundGuarantee);
	}
	
	@Override
	public boolean checkTecYear(String year, String id){
		return fundGuaranteeDao.checkProperty("testYear", year, id);
	}
}
